﻿using Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hotfix
{
    [MessageHandler(AppType.Gate)]
    public class C2G_TestHandler : AMRpcHandler<C2S_Test, S2C_Test>
    {
        protected override async void Do(Session session, C2S_Test request, Action<S2C_Test> reply)
        {
            // Log.Info($"{request.ToJson()}");

            StartConfigComponent startConfigComponent = Game.Scene.GetComponent<StartConfigComponent>();
            NetInnerComponent innerComponent = Game.Scene.GetComponent<NetInnerComponent>();

            StartConfig startConfig = startConfigComponent.DBConfig;

            Session s = innerComponent.Get(startConfig.GetInnerIP());

            D2G_Test temp = await s.Call<D2G_Test>(new G2D_Test { Id = 1 });

            Log.Info($"Rpc:回应 {temp.ToJson()}");

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 512; i++)
            {
                sb.Append("啊");
            }

            reply(new S2C_Test
            {
                Id = 1,
                Name = sb.ToString()
            });
        }
    } 
}
